// pages/scenter/editpass.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    code:'',
    newpass:'',
    oldpass:'',
    mobile:'',
  },
  navigateBack() {
    wx.navigateBack({
      delta: 1
    })
  },
  getnewpass(e){
    let that = this
    console.log(e.detail.value)
    that.setData({
      newpass:e.detail.value
    })
  },
  getoldpass(e){
    let that = this
    console.log(e.detail.value)
    that.setData({
      oldpass:e.detail.value
    })
  },
  adddetermine(e){
    let that = this
    let code = that.data.code
    let newpass = that.data.newpass
    let oldpass = that.data.oldpass
    let mobile = that.data.mobile
    let token = wx.getStorageSync('token')
   // let token = wx.getStorageSync('token')
    if(newpass==oldpass){
      //设置企业支付密码
      wx.request({
        url: 'https://www.yulonging.com/dwweb/wxapi.ashx',
        data: {
         //请求后台的分页数据
         cmd:'setPayPwd',
         token:token,
         Pwd:newpass,
         IsCorp:1,
         mobile:mobile,
         Yzm:code,
        },
        method: "get",
        success(res) {
          console.log(res.data.STATUS)
            if(res.data.STATUS=='Success'){
              wx.showToast({
                title: '设置成功',
                icon: 'success',
                duration: 1000
              })
               setTimeout(function (e) {
                wx.switchTab({
                  url: '../index/index',
                })
                }, 2000)
            }else{
              wx.showToast({
                title: res.data.DESC,
                icon: 'error',
                duration: 2000
              })
            }
        }
        })
    }else{
      wx.showToast({
        title: '两次密码必须一致',
        icon: 'error',
        duration: 2000
      })
    }



  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    that.setData({
      code:options.code,
      mobile:options.mobile,
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})